<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Grom Hellscream
 * Date: 11/2/12
 * Time: 11:33 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();

$canbo = $this->get('canbo');
$phongs = $this->get('phong');
$item = $this->get('item');
$congtrinh = $this->get('congtrinh');
if (count($phongs) > 1) 
    $phong = $phongs[0];
elseif (count($phongs) == 1)
    $phong = $phongs;
$donvis = $this->get('donvi');
if (count($donvis) > 1)
    $donvi = $donvis[0];
elseif (count($donvis) == 1)
    $donvi = $donvis;
$khoi = $this->get('khoi');
$hosocanbo = VastHelper::getHosocanbo();
if (!JFactory::getUser()->authorise('vast.tailieu.create', 'com_vast') && !(JFactory::getUser()->authorise('vast.tailieu.manage.own') && $hosocanbo != NULL && $hosocanbo->nguoidung_id == JFactory::getUser()->id))
{
    JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_vast&view=vast'));                        
}
?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <?php if (isset($khoi) && $khoi !== NULL): ?>        
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=donvitructhuoc&id=' . $khoi->id); ?>"><?php echo $khoi->ten ?></a> »                
        <?php endif; ?>
        <?php if (isset($donvi) && $donvi !== NULL): ?>
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=phongtructhuocs&id=' . $donvi->id); ?>"><?php echo $donvi->ten ?></a> »
        <?php endif; ?>
        <?php if (isset($phong) && $phong !== NULL): ?>
        <span><?php echo $phong->ten; ?></span> »        
        <?php endif; ?>
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=chitietcanbo&id=' . $canbo->id); ?>"><?php echo $canbo->hoten; ?></a> »
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=quanlycongtrinh&layout=view&congtrinhid=' . $item['congtrinh_id'] .'&id=' . $congtrinh->hosocanbo_id); ?>"><?php echo $congtrinh->ten; ?></a> »
        <span>Cập nhật tài liệu</span>
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">Cập nhật tài liệu cho công trình <?php echo $congtrinh->ten; ?></h3>
    
    <div class="form">
        <form class="commentform" action="<?php echo JRoute::_('index.php?option=com_vast&view=tailieu&layout=edit&congtrinhid=' . $congtrinh->id); ?>" method="post" id="tailieu" name="tailieu" enctype="multipart/form-data">
            
            <div class="row">
                <?php echo $this->form->getLabel('id'); ?>
                <?php echo $this->form->getInput('id'); ?>
            </div>
                    
            <div class="row">
                <?php echo $this->form->getLabel('congtrinh_id'); ?>
                <?php echo $this->form->getInput('congtrinh_id'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('dinhkem'); ?>
                <input type="file" name="file_upload" id="file_upload"/>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('mota'); ?>
                <?php echo $this->form->getInput('mota'); ?>
            </div>

            <div class="row">
                <input type="hidden" name="option" value="com_vast" />
                <input type="hidden" name="task" value="tailieu.update" />
            </div>
            
            <div class="row buttons">
                <button type="submit" class="button" id="submit"><?php echo JText::_('Cập nhật tài liệu'); ?></button>
                <?php echo JHtml::_('form.token'); ?>
            </div>
        </form>
    </div>
</div>